﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;

namespace Nightlife.Models
{
    public partial class NightlifeDB
    {
        public SpotModel GetSpot(int id)
        {
            return db.Spots.FirstOrDefault(s => s.ID == id);
        }

        public List<SpotModel> GetAllSpots()
        {
            return db.Spots.ToList();
        }

        public void Add(SpotModel spot)
        {
            db.Spots.Add(spot);
            db.SaveChanges();
        }

        public void Update(SpotModel spot)
        {
            db.Entry(spot).State = EntityState.Modified;
            db.SaveChanges();
        }

        public void Delete(SpotModel spot)
        {
            db.Spots.Remove(spot);
            db.SaveChanges();
        }

        public void Dispose()
        {
            db.Dispose();
        }
    }
}